package top.dark.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.dark.dao.product.AttrDao;
import top.dark.dao.product.PUserDao;
import top.dark.pojo.AttrEntity;
import top.dark.pojo.UserEntity;
import top.dark.service.AttrService;

/**
 * Author: Lijiao
 * description:
 * Create Time: 2021/5/13 15:04
 */
@Service
public class AttrServiceImpl implements AttrService {

    @Autowired
    private AttrDao attrDao;
    @Autowired
    private PUserDao pUserDao;

    @Transactional(rollbackFor = Exception.class,transactionManager = "pmsManagerOne")
    public void updateAttr() {
        AttrEntity attrEntity = new AttrEntity();
        attrEntity.setAttrId(7L);
        attrEntity.setAttrName(UserServiceImpl.name);
        attrDao.updateTemplateById(attrEntity);

        updatePUser();

        getSum();
    }
    public void getSum(){
        int a = 1 / 0;
        System.out.println(a);
    }

    @Transactional(rollbackFor = Exception.class,transactionManager = "pmsManagerOne")
    public void updatePUser(){
        UserEntity userEntity = new UserEntity();
        userEntity.setId(1);
        userEntity.setName(UserServiceImpl.name);
        pUserDao.updateTemplateById(userEntity);
    }
}
